package name.panitz.ludens.strategy;
import javax.swing.*;
import java.util.List;

class AlphaBetaOthelloControl extends OthelloControl{
  AlphaBetaOthelloControl(Othello g){super(g);}
  AlphaBetaOthelloControl(){this(new Othello());}

  class AlphaBetaOthello extends AlphaBetaGame<OthelloMove>{
    @Override int getDepth(){return 9;}
  }

  @Override public void whenMousePressed(byte c,byte r){
    if (board.getGame().ended()) return;
    if (board.getGame().currentPlayer()==Othello.ONE)
      board.setGame(
       (Othello)new AlphaBetaOthello()
                     .doBestMove(board.getGame()));
    else {
      final List<OthelloMove>ms
        =(List<OthelloMove>)board.getGame().moves();
      if (ms.get(0) instanceof NoMove)
        board.setGame(
          ((Othello)board.getGame()).doMove(ms.get(0)));
      super.whenMousePressed(c,r);
    }
  }

  public static void main(String[] args){
    JFrame f=new JFrame("Othello");
    f.add(new AlphaBetaOthelloControl());
    f.pack();f.setVisible(true);
  }
}

